import httpInstance from "@/utils/http"

export function uploadShard(chunkData, onProgressCallback) {
    return httpInstance({
        method: "post",
        url: "/file/upload/shard",
        headers: {
            'Content-Type': 'multipart/form-data',
        },
        onUploadProgress: onProgressCallback,
        data: chunkData
    })
}

export function uploadSecondsPass(fileSeconds) {
    return httpInstance({
        method: "post",
        url: "/file/upload/seconds",
        data: fileSeconds
    })
}

export function fileExist(fileMd5) {
    return httpInstance({
        method: "get",
        url: "/file/md5/" + fileMd5
    })
}

export function shardExist(shardMd5) {
    return httpInstance({
        method: "get",
        url: "/file/shardMd5/" + shardMd5
    })
}

export function preview(fileId) {
    return httpInstance({
        method: "get",
        url: "/file/preview/" + fileId
    })
}

export function downloadFileAxios(fileList) {
    return httpInstance({
        method: "post",
        url: "/file/downloadList" ,
        data: fileList,
        responseType: "blob"
    })
}

export function downloadOneFile(minioName) {
    return httpInstance({
        method: "get",
        url: `/file/download/${minioName}`,
        responseType: "blob"
    })
}




